﻿using System;


namespace TestHost
{
    class Program
    {
        static void Main(string[] args)
        {
            /*Command to run as non-admin: netsh http add urlacl url=http://+:8000/Service user=DOMAIN\USER */




            //string baseAddress = "http://" + Environment.MachineName + ":8000/Service";
            //ServiceHost host = new ServiceHost(typeof(Service), new Uri(baseAddress));
            //ServiceEndpoint ep1 = host.AddServiceEndpoint(typeof(ITest), new BasicHttpBinding(), "basic");
            //ep1.Name = "Endpoint1-BasicHttp";
            //ep1.Behaviors.Add(new DebugEndpointBehavior());

            //ServiceEndpoint ep2 = host.AddServiceEndpoint(typeof(ITest2), new WSHttpBinding(), "ws");
            //ep2.Name = "Endpoint2-WSHttp";
            //ep2.Behaviors.Add(new DebugEndpointBehavior());

            //Console.WriteLine("Opening the host...");
            //host.Open();
            //Console.WriteLine("Host opened");


            string baseAddress = "http://" + Environment.MachineName + ":8000/Service";
            //PocoServiceHost host = new PocoServiceHost(new SimpleService("ZoomBot"), new Uri(baseAddress));
            //PocoServiceHost host = new PocoServiceHost(typeof(SimpleService), new Uri(baseAddress));

			Granite.Wcf.PocoService.PocoServiceHost host = new Granite.Wcf.PocoService.PocoServiceHost(typeof(SimpleService), new Uri(baseAddress), () => new SimpleService("ZoomBot"));


            host.Open();

            Console.WriteLine("Press ENTER to close");
            Console.ReadLine();
            host.Close();

                       
        }
    }

    public class SimpleService 
    {
        readonly string m_Name;

        //public SimpleService() { }

        public SimpleService(string name)
        {
            m_Name = name;
        }

        public int Add(int x, int y) { return x + y; }
        public int Multiply(int x, int y) { return x * y; }
        public string Echo(string text) { return m_Name + " says " + text; }
    }
}
